package com.hongxun.project.assets.bModelItem.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hongxun.framework.aspectj.lang.annotation.Log;
import com.hongxun.framework.aspectj.lang.enums.BusinessType;
import com.hongxun.project.assets.bModelItem.domain.BModelItem;
import com.hongxun.project.assets.bModelItem.service.IBModelItemService;
import com.hongxun.framework.web.controller.BaseController;
import com.hongxun.framework.web.page.TableDataInfo;
import com.hongxun.framework.web.domain.AjaxResult;
import com.hongxun.common.utils.poi.ExcelUtil;

/**
 * 模块子 信息操作处理
 * 
 * @author hongxun
 * @date 2019-07-10
 */
@Controller
@RequestMapping("/assets/bModelItem")
public class BModelItemController extends BaseController
{
    private String prefix = "assets/bModelItem";
	
	@Autowired
	private IBModelItemService bModelItemService;
	
	@RequiresPermissions("assets:bModelItem:view")
	@GetMapping()
	public String bModelItem()
	{
	    return prefix + "/bModelItem";
	}
	
	/**
	 * 查询模块子列表
	 */
	@RequiresPermissions("assets:bModelItem:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BModelItem bModelItem)
	{
		startPage();
        List<BModelItem> list = bModelItemService.selectBModelItemList(bModelItem);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出模块子列表
	 */
	@RequiresPermissions("assets:bModelItem:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BModelItem bModelItem)
    {
    	List<BModelItem> list = bModelItemService.selectBModelItemList(bModelItem);
        ExcelUtil<BModelItem> util = new ExcelUtil<BModelItem>(BModelItem.class);
        return util.exportExcel(list, "bModelItem");
    }
	
	/**
	 * 新增模块子
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存模块子
	 */
	@RequiresPermissions("assets:bModelItem:add")
	@Log(title = "模块子", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BModelItem bModelItem)
	{		
		return toAjax(bModelItemService.insertBModelItem(bModelItem));
	}

	/**
	 * 修改模块子
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		BModelItem bModelItem = bModelItemService.selectBModelItemById(id);
		mmap.put("bModelItem", bModelItem);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存模块子
	 */
	@RequiresPermissions("assets:bModelItem:edit")
	@Log(title = "模块子", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BModelItem bModelItem)
	{		
		return toAjax(bModelItemService.updateBModelItem(bModelItem));
	}
	
	/**
	 * 删除模块子
	 */
	@RequiresPermissions("assets:bModelItem:remove")
	@Log(title = "模块子", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(bModelItemService.deleteBModelItemByIds(ids));
	}
	
}
